#ifndef PERFORMANCE_H
#define PERFORMANCE_H

#include <QWidget>
#include "ettadatastruct.h"
#include "blldataflow.h"
#include "sqlhelper.h"
#include "volttestresult.h"
#include "flowtestresult.h"
#include "commonfunction.h"
#include "testloading.h"
#include "datetimepicker.h"
#include "project.h"
#include "iexportable.h"

namespace Ui {
class Performance;
}

class IMeasure;
class IDataExport;
class Performance : public QWidget, public IExportable
{
    Q_OBJECT

public:
    explicit Performance(QWidget *parent = nullptr);
    ~Performance();

    void save(const QString &path);

private slots:
    void on_btnVoltRec_clicked();
    void on_btnVoltReturn_clicked();
    void on_btnVoltPrint_clicked();
    void on_btnVoltExport_clicked();
    void on_btnVoltTest_clicked();
    void on_btnVoltQuery_clicked();

    void on_btnFlowRec_clicked();
    void on_btnFlowReturn_clicked();
    void on_btnFlowPrint_clicked();
    void on_btnFlowExport_clicked();
    void on_btnFlowTest_clicked();
    void on_btnFlowQuery_clicked();

    void setWidgetVisibleSlot(int permission);
    void retranslateUiSlot();

    void on_btnDatetimeVoltStart_clicked();
    void on_btnDatetimeVoltEnd_clicked();
    void on_btnDatetimeFlowStart_clicked();
    void on_btnDatetimeFlowEnd_clicked();

    void changeDateTime(QDateTime dateTime, QString whatsThis);
    void setReportHtml(int type, const QString html);
    void setCurrentTimeSlot(int type);
    void setWidgetParent();

    void pdfSaveDone(const QString &info, const QString &path);
    void voltTestProgress(const QString &info, bool stopped);
    void flowTestProgress(const QString &info, bool stopped);

private:
    void initWidget();
    QString generateVoltTestTable(const QList<VoltTest> &voltList);
    QString generateFlowTestTable(const QList<FlowTest> &flowList);
    void initVoltTestTable();
    void initFlowTestTable();
    void retranslateTable();
    void initTableHeader();
    void clearVoltageTable();
    void clearFlowTable();

private:
    Ui::Performance *ui;    
    BllDataFlow * bdf;
    SqlHelper * sqlHelper;
    VoltTestResult * voltTestRes;
    FlowTestResult * flowTestRes;
    TestLoading * testLoading;
    VoltTest voltTest;
    FlowTest flowTest;
    DateTimePicker * dateTimePicker;
    QList<VoltTest> voltList;
    QList<FlowTest> flowList;
    QString contentHtml;
    QString voltContentHtml;
    QString flowContentHtml;
    QString voltReportHtml;
    QString flowReportHtml;
    QStringList voltTableHeader;
    QStringList flowTableHeader;
    ReportType exportType;
    IDataExport *exportMgr;
    IMeasure *voltMeasureMgr;
    IMeasure *flowMeasureMgr;
};

#endif // PERFORMANCE_H
